#include "onvif_server.h"
#include "onvif_server_impl.h"

namespace El {
namespace Onvif {

OnvifServer::OnvifServer(int port) : pImpl_(std::make_unique<OnvifServerImpl>(port)) {}

OnvifServer::~OnvifServer() = default;

bool OnvifServer::Start() {
    return pImpl_->Start();
}

void OnvifServer::Stop() {
    pImpl_->Stop();
}

bool OnvifServer::IsRunning() const {
    return pImpl_->IsRunning();
}

void OnvifServer::SetDeviceInformation(const DeviceInformation& deviceInfo) {
    pImpl_->SetDeviceInformation(deviceInfo);
}

DeviceInformation OnvifServer::GetDeviceInformation() const {
    return pImpl_->GetDeviceInformation();
}

void OnvifServer::SetNetworkConfiguration(const NetworkInterface& networkConfig) {
    pImpl_->SetNetworkConfiguration(networkConfig);
}

NetworkInterface OnvifServer::GetNetworkConfiguration() const {
    return pImpl_->GetNetworkConfiguration();
}

void OnvifServer::SetOnvifPort(int port) {
    pImpl_->SetOnvifPort(port);
}

int OnvifServer::GetOnvifPort() const {
    return pImpl_->GetOnvifPort();
}

void OnvifServer::EnableWSDiscovery(bool enable) {
    pImpl_->EnableWSDiscovery(enable);
}

bool OnvifServer::IsWSDiscoveryEnabled() const {
    return pImpl_->IsWSDiscoveryEnabled();
}

void OnvifServer::SetSecurityMode(SecurityMode mode) {
    pImpl_->SetSecurityMode(mode);
}

SecurityMode OnvifServer::GetSecurityMode() const {
    return pImpl_->GetSecurityMode();
}

bool OnvifServer::AddUser(const User& user) {
    return pImpl_->AddUser(user);
}

bool OnvifServer::RemoveUser(const std::string& username) {
    return pImpl_->RemoveUser(username);
}

std::vector<User> OnvifServer::GetUsers() const {
    return pImpl_->GetUsers();
}

bool OnvifServer::AddMediaProfile(const MediaProfile& profile) {
    return pImpl_->AddMediaProfile(profile);
}

bool OnvifServer::RemoveMediaProfile(const std::string& token) {
    return pImpl_->RemoveMediaProfile(token);
}

std::vector<MediaProfile> OnvifServer::GetMediaProfiles() const {
    return pImpl_->GetMediaProfiles();
}

ServiceCapabilities OnvifServer::GetServiceCapabilities() const {
    return pImpl_->GetServiceCapabilities();
}

// 工厂实现
std::unique_ptr<IOnvifServer> OnvifServerFactory::CreateServer(int port) {
    return std::make_unique<OnvifServer>(port);
}

// 全局工厂函数
std::unique_ptr<IOnvifServerFactory> CreateOnvifServerFactory() {
    return std::make_unique<OnvifServerFactory>();
}

} // namespace Onvif
} // namespace El